package com.kun.portal.webframe.util.MessageFormatImp;

import com.kun.portal.webframe.po.AppointmentPo;
import com.kun.portal.webframe.util.MessageFilter;
import com.kun.portal.webframe.util.MessageFormat;

import java.text.SimpleDateFormat;

public class TransformToFlightPlane implements MessageFormat {

    public TransformToFlightPlane(AppointmentPo appointmentPo){
        this.appointmentPo = appointmentPo;
    }
    private AppointmentPo appointmentPo;
    @Override
    public String getMessageContext() {
        String messageContent = "";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH点");
        SimpleDateFormat flightTime = new SimpleDateFormat("yyyy年MM月dd日 HH点");
        String date = "";
        try{
            date=  simpleDateFormat.format(appointmentPo.getAppoDate());
        }catch (Exception e){
            e.printStackTrace();
        }
        String takeOffTime = appointmentPo.getFlightPlane()==null?"":appointmentPo.getFlightPlane().getTakeOffTime()==null?"":flightTime.format(appointmentPo.getFlightPlane().getTakeOffTime());
        String arriveTime = appointmentPo.getFlightPlane()==null?"":appointmentPo.getFlightPlane().getArriveTime()==null?"":flightTime.format(appointmentPo.getFlightPlane().getArriveTime());
        messageContent+= appointmentPo.getAppoUnit()+"单位的 "+ appointmentPo.getAppoName() +" 预约的 " +date +"的由"+ appointmentPo.getOriginating()+
                "飞往" +appointmentPo.getDestination() +"的"+appointmentPo.getFlightInfo().getFlightNum()+"次航班预计划已生成 预计起飞时间 "+takeOffTime +"预计落地时间 "+arriveTime+"  请注意处理" ;
        return messageContent;
    }
}
